<?php

class micontentModule extends Module {
	/*
	 * 在构造函数中装载所依赖的类或其他文件
	*/
	function __construct() {
		$this->includePhp('micontent', 'micontent');
	}
	
	
	/*
	 * 调用插件资源
	*/
	public function call($user, $method, $param) {
		//检查用户
//		$customerId = Session::$user['customerId'];
//		Session::switchCustomer(0);
//		$uid = Session::$user['uid'];
//		$quanUserModel=M("quan_user");
//		Session::switchCustomer($customerId);
//		$fromUId=$param->fromUId;
//		$fromGuid=$param->fromGuid;
//		$allowMethod="getMiContent|getMiContentDetail";
//		if(strpos($allowMethod,$method) && (!$fromUId && !$fromGuid)){
//			if(!$uid){
//				return;
//			}
//			$user=$quanUserModel->where("uid=$uid")->select();
//			if(!$user || count($user) < 1){
//				Output::instance()->resultCode(1,"无权限访问");
//				return;
//			}
//			//判断是否主公身份
//			if($param){
//				$uType=$param->uType;
//				if($uType && $uType==1){
//					if($user["identity"] == 1){
//						Output::instance()->resultCode(1,"无权限访问");
//						return;
//					}
//				}
//			}
//		}
		switch ($method) {
			case "getMiContentList":
			    $qId=$param->qId;
			    if (!isset($qId)) {
			        Output::instance()->resultCode(code_lackof_param);
			        return;
			    }
			    micontent::getMiContentList($qId,$param->order,$param->start,$param->limit);
			    break;
			 case "getMiContentDetail":			    
			    $id=$param->id;			        
			    if (!isset($id)) {			            
			         Output::instance()->resultCode(code_lackof_param);
			         return;
			    }
			    micontent::getMiContentDetail($param);
			    break; 
			 //获取内容详情
			 case "getObjectDetail":
			 	$id=$param->id;			        
			    if (!isset($id)) {			            
			         Output::instance()->resultCode(code_lackof_param);
			         return;
			    }			        
			    return micontent::getObjectDetail($param);
			    break;
			 case 'getMiContent':
		        micontent::getMiContent($param);
		        break;
		     case 'saveComment':
		     	micontent::saveComment($param);
		        break;
		     case 'getCommentList':
		     	micontent::getCommentList($param);
		     	break;
		     case "getMiContentByAccessTag":			         
		        $id=$param->id;			         
		        if (!isset($id)) {
		            Output::instance()->resultCode(code_lackof_param);
		            return;
		        }
		        micontent::getMiContentByAccessTag($param);
		       break;
			 case "getUserMiContentData":
				$moduleId = $param->moduleId;
				$type = $param->type;
				$start = $param->start?$param->start:0;
				$limit = $param->limit?$param->limit:10;
				$moduleType = $param->moduleType?$param->moduleType:'micontent';
				micontent::getUserMiContentData($moduleId,$type,$start, $limit,$moduleType);
				break;
			case 'submitSucc':
				return micontent::formOrderSubmitPage();
				break;
			case 'getRewardInfo':
				return micontent::getRewardInfo($param);
				break;
			case 'receiveReward':
				return micontent::receiveReward();
				break;
			case 'RewardSubmitInfo':
				return micontent::RewardSubmitInfo($param);
				break;
			case 'isPartner':
				return micontent::isPartner();
				break;
			case 'getMiUserRewardList':
				if(!$param->start){
					$param->start = 0;
				}
				if(!$param->limit){
					$param->limit = 10;
				}
				return micontent::getMiUserRewardList($param);
				break;
		}
	}
}


$module = new micontentModule();
Module::addModule($module);
?>